<?php 
defined('IN_TS') or die('Access Denied.'); 

function newwish(){
	global $db;
	//最新心愿
	if( $GLOBALS['TS_USER']!=''){
		$mylink = '&link='.$GLOBALS['TS_USER']['userid'];
	}
	$arrWishs = aac('wish')->findAll('wish',
		'isaudit=0 and quota>count_userdo and limittime>'.time()
	,'addtime desc','',5);

	if (count($arrWishs) > 0) {
		$userids = array_column($arrWishs, "userid");
		$users = aac('user')->getUsers($userids);

		$wishTypes = aac('wish')->getWishTypes();
	}

	
	foreach($arrWishs as $key=>$item){

		    $arrWish[] = $item;
			$arrWish[$key]['title']=tsTitle($item['title']);
			$arrWish[$key]['user'] = $users[$item["userid"]];
			$arrWish[$key]['type'] = $wishTypes[$item['typeid']];
		   }

	include template('newwish','newwish');
	
}

function newwish_css(){

	echo '<link href="'.SITE_URL.'plugins/home/newwish/style.css" rel="stylesheet" type="text/css" />';

}

addAction('home_index_left','newwish');
addAction('pub_header_top','newwish_css');